package drive.RemakeService.ServiceFormat;



import com.google.gson.Gson;
import drive.Mapper.ArticleMapper;
import drive.Mapper.RoadDisasterMapper;
import drive.Model.Article;
import drive.Model.RoadDisaster;
import drive.RemakeService.ServiceInterface.TravelMapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TravelMapServiceA implements TravelMapService {
    @Autowired
    ArticleMapper articleMapper;

    @Autowired
    RoadDisasterMapper roadDisasterMapper;
    Gson gson = new Gson();

    @Override
    public String getNearbyTravelNotes(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) {
        List<Article> articles = articleMapper.getArticlesByLocation(minLatitude, maxLatitude, minLongitude, maxLongitude);
        return gson.toJson(articles);
    }

    @Override
    public String getNearbyDisasters(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) {
        List<RoadDisaster> disasters = roadDisasterMapper.getDisastersByLocation(minLatitude, maxLatitude, minLongitude, maxLongitude);
        return gson.toJson(disasters);
    }

    @Override
    public String getDisasterDetails(Integer disasterID) {
        // 实现获取灾害详情逻辑
        return "获取灾害详情成功";
    }

    @Override
    public String searchDestination(String destination) {
        // 实现搜索目的地逻辑
        return "搜索目的地成功";
    }

    @Override
    public String updateDisaster(Integer disasterID, String updateInfo) {
        // 实现更新灾害信息逻辑
        return "更新灾害信息成功";
    }
}